# Check server health via the idrac
# this == for Dell servers ONLY
# these values are configurable
define hostgroup {
	hostgroup_name idrac
        alias Mgmt iDRAC
}

{% for host in groups['idrac'] %}
define host {
	use                     linux-server
	host_name               {{ host }}
	alias                   {{ host }}
	address                 {{ hostvars[host].ansible_host }}
	hostgroups 		        idrac
}
{% endfor %}

{% if idrac_vdisk == true %}

# check vdisks if set to true in all.yml
define service {
	use				            generic-service
	hostgroup_name			    idrac
	service_description	        iDRAC Server RAID
	check_command			    check_idrac_vdisk
	notifications_enabled		1
    # check once an hour
    check_interval              60
}
{% endif %}

{% if idrac_disk == true %}

# check disks if set to true in all.yml
define service {
	use				            generic-service
	hostgroup_name			    idrac
	service_description	        iDRAC Server DISK
	check_command			    check_idrac_disk
	notifications_enabled		1
    # check once an hour
    check_interval              60
}
{% endif %}

{% if idrac_ps == true %}

# check ps if set to true in all.yml
define service {
	use				            generic-service
	hostgroup_name			    idrac
	service_description	        iDRAC Server PSU
	check_command			    check_idrac_ps
	notifications_enabled		1
    # check once an hour
    check_interval              60
}
{% endif %}

{% if idrac_fan == true %}

# check FAN if set to true in all.yml
define service {
	use				            generic-service
	hostgroup_name			    idrac
	service_description	        iDRAC Server FAN
	check_command			    check_idrac_fan
	notifications_enabled		1
    # check once an hour
    check_interval              60
}
{% endif %}

{% if idrac_battery == true %}

# check battery if set to true in all.yml
define service {
	use				            generic-service
	hostgroup_name			    idrac
	service_description	        iDRAC Server BATTERY
	check_command			    check_idrac_battery
	notifications_enabled		1
    # check once an hour
    check_interval              60
}
{% endif %}

{% if idrac_pu == true %}

# check power redundancy if set to true in all.yml
define service {
	use				            generic-service
	hostgroup_name			    idrac
	service_description	        iDRAC Server POWER
	check_command			    check_idrac_pu
	notifications_enabled		1
    # check once an hour
    check_interval              60
}
{% endif %}

{% if idrac_mem == true %}

# check memory if set to true in all.yml
define service {
	use				            generic-service
	hostgroup_name			    idrac
	service_description	        iDRAC Server MEM
	check_command			    check_idrac_mem
	notifications_enabled		1
    # check once an hour
    check_interval              60
}
{% endif %}

{% if idrac_sensor == true %}

# check temperature sensors if set to true in all.yml
define service {
	use				            generic-service
	hostgroup_name			    idrac
	service_description	        iDRAC Server TEMP
	check_command			    check_idrac_sensor
	notifications_enabled		1
    # check once an hour
    check_interval              60
}
{% endif %}

{% if idrac_cpu == true %}

# check cpu if set to true in all.yml
define service {
	use				            generic-service
	hostgroup_name			    idrac
	service_description	        iDRAC Server CPU
	check_command			    check_idrac_cpu
	notifications_enabled		1
    # check once an hour
    check_interval              60
}
{% endif %}

# service checks for general idrac connectivity.
# service checks to be applied to idrac interfaces
define service {
	use				            local-service
	hostgroup_name			    idrac
	service_description	        Web Interface
	check_command			    check_http
	notifications_enabled		1
}
define service {
	use				            local-service
	hostgroup_name			    idrac
	service_description	        SSH
	check_command			    check_ssh
	notifications_enabled		1
}
define service {
	use				            generic-service
	hostgroup_name			    idrac
	service_description	        PING
	check_command			    check_ping!200.0,20%!600.0,60%
	notifications_enabled		1
}
